package alejandro.castro.visual;

import java.awt.Color;
import java.awt.Graphics2D;

import com.uqbar.vainilla.GameComponent;
import com.uqbar.vainilla.appearances.Appearance;

public class BolitaAppearance implements Appearance{

	private int diameter;
	private int bgDiameter;
	private int bgMargin;
	Color borderColor;
	Color bgColor;
	
	public BolitaAppearance(int diameter) {
		this.diameter = diameter;
		this.bgDiameter = (int) Math.floor(diameter* 0.70);
		this.bgMargin = (diameter - bgDiameter) / 2;
		this.borderColor = new Color(191, 255, 191);
		this.bgColor = new Color(0, 0, 0);		
	}
	
	@Override
	public double getWidth() {
		return diameter;
	}

	@Override
	public double getHeight() {
		return diameter;
	}

	@Override
	@SuppressWarnings("unchecked")
	public BolitaAppearance copy() {
		return new BolitaAppearance(diameter);
	}

	@Override
	public void update(double delta) {
		//Nothing here		
	}

	@Override
	public void render(GameComponent<?> component, Graphics2D graphics) {
		graphics.setColor(borderColor);
		graphics.fillOval((int) component.getX(), (int) component.getY(), this.diameter, this.diameter);
		graphics.setColor(bgColor);
		graphics.fillOval((int) component.getX() + bgMargin, (int) component.getY() + bgMargin, this.bgDiameter, this.bgDiameter);
		
	}
	
	public void setBgColor(Color bgColor) {
		this.bgColor = bgColor;
	}

}
